import request from '@/utils/request'
import qs from 'qs'
<#assign  myPath = entity ? uncap_first>
export function getPage(query) {
  return request({
    url: '/${myPath}/page',
    method: 'post',
    headers: {
      'Content-Type': 'application/json;charset=utf-8'
    },
    data: JSON.stringify(query)
  })
}

export function getDetail(id) {
  return request({
    url: '/${myPath}/detail/' + id,
    method: 'get'
  })
}

export function createEntity(data) {
  return request({
    url: '/${myPath}/add',
    method: 'post',
    headers: {
      'Content-Type': 'application/json;charset=utf-8'
    },
    data: JSON.stringify(data)
  })
}

export function updateEntity(data) {
  return request({
    url: '/${myPath}/update',
    method: 'post',
    headers: {
      'Content-Type': 'application/json;charset=utf-8'
    },
    data: JSON.stringify(data)
  })
}

export function deleteEntity(data) {
  let arr = ''
  for (const id of data) {
    arr += id + ','
  }
  return request({
    url: '/${myPath}/delete?ids=' + arr.substr(0, arr.length - 1),
    method: 'post'
  })
}

